package com.woniuxy.controller;


import com.woniuxy.controller.info.MenuInfo;
import com.woniuxy.service.MenusService;
import com.woniuxy.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hujianying
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/menus")
@Api(tags = "菜单相关接口")
public class MenusController {
    @Resource
    private MenusService menusService;

    /**
     *
     * @return data为allMenus菜单集合
     */
    @ApiOperation("获取所有菜单")
    @GetMapping("/findMenus")
    public Result getAllMenus(Integer accountId){
        List<MenuInfo> allMenus = menusService.getAllMenus(accountId);
        return Result.success(200,"查询成功",allMenus);
    }

    //根据角色id查询所有的菜单
    @ApiOperation("根据角色id查询所有的菜单")
    @GetMapping("/findMenueByruleId")
    public Result findMenueByruleId(Integer id){
        List<MenuInfo> menueByruleId = menusService.findMenueByruleId(id);

        return Result.success(200,"请求成功",menueByruleId);
    }
}

